<?

class RelationattributeController extends Vakanz_CRM_Controller_Adminaction {


	public function editAction() {
		$attributes = new Vakanz_Attributes();
		$relations = new Vakanz_Relations();
		$attributesRs = $attributes->fetchAll($attributes->select()->order('attribute_position'));
		$this->view->attributes = $attributesRs->toStdObjectArray();
		$relation_id = $this->_getParam('relation_id');
		if (intval($relation_id) != 0) {
			$relation = $relations->fetchRow($relations->select()->where('relation_id = ?', $relation_id));
			$relationAttributes = $relation->findVakanz_Relation_Attributes($relation->select()->where('relationattribute_status = ?' , 10));
			$raArray = array();
			foreach ($relationAttributes as $relationAttribute) {
				$raArray[] = $relationAttribute->attribute_id;
			}
			$this->view->relationattributes = $raArray;
		} else {
			$this->view->relationattributes = array();
		}
		$this->view->debug = $this->_request->getParams();
	}
}